//
//  BQMapViewController.m
//  BeeQuick
//
//  Created by Asun on 2017/7/11.
//  Copyright © 2017年 BecomeRich. All rights reserved.
//

#import "BQMapViewController.h"
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
@interface BQMapViewController ()

@property (strong,nonatomic)MKMapView *mapView;
@property (strong, nonatomic)UITextField *textFiled;
@property (strong, nonatomic) CLLocationManager *mgr;
@end

@implementation BQMapViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.navigationItem.title = @"定位当前所在位置";
    

    
    self.navigationController.navigationBar.translucent = NO;
    
    self.mapView = [[MKMapView alloc]init];
    
    [self.view addSubview:self.mapView];
    
    [self.mapView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    
    
    self.textFiled = [[UITextField alloc]init];
    
    self.textFiled.placeholder = @"请输入目的地";
    
    self.textFiled.borderStyle =  UITextBorderStyleRoundedRect;
    
    [self.mapView addSubview:self.textFiled];
    
    [self.textFiled mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mapView).offset(10);
        
        make.leading.equalTo(self.view).offset(10);
        
        make.height.offset(30);
        
        make.width.offset(300);
    }];
    
    UIButton * btn = [[UIButton alloc]init];
    
    btn.layer.cornerRadius = 10;
    
    btn.layer.masksToBounds = YES;
    
    [btn setTitle:@"查询" forState:UIControlStateNormal];
    
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [btn setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
    
    btn.backgroundColor = [UIColor lightGrayColor];
    
    [self.mapView addSubview:btn];
    
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.textFiled);
        make.leading.equalTo(self.textFiled.mas_trailing).offset(10);
        make.trailing.offset(-10);
    }];
    
     

    // 用户位置当前的位置信息
    self.mgr = [CLLocationManager new];
    
    // 请求用户授权
    [self.mgr requestWhenInUseAuthorization];
    
    self.mapView.userTrackingMode = MKUserTrackingModeFollow;
    
    
    

}
@end
